package com.matt.controller.web;

import com.matt.commons.dto.sso.StaffDTO;
import com.matt.foundation.constant.RequestConstant;
import com.matt.foundation.model.MemVerificationCache;
import com.matt.commons.model.StatusResponse;
import com.matt.foundation.query.AdviseQuery;
import com.matt.foundation.query.AreaCourseQuery;
import com.matt.foundation.vo.AdviseListVo;
import com.matt.foundation.vo.course.AreaCourseListVo;
import com.matt.service.CourseEarlyService;
import com.matt.service.GardenLeaderService;

import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/9/19
 * *******************************
 */
@RestController
@RequestMapping("/web/garden_leader")
public class WebGardenLeaderController {

    @Autowired
    private GardenLeaderService gardenLeaderService;

    @Autowired
    private MemVerificationCache cache;

    @Autowired
    private CourseEarlyService courseService;

    @ApiOperation(value = "园长建议列表",httpMethod = "POST")
    @RequestMapping("/advise_page")
    public StatusResponse goPreparePage(@RequestHeader(RequestConstant.TICKET) String ticket, AdviseQuery query) {

        query.setStaffId(cache.getStaffId(ticket));
        Page<AdviseListVo> advisePage = gardenLeaderService.getAdviseList(query);
        return StatusResponse.success(advisePage);
    }

    @ApiOperation(value = "添加园长建议",httpMethod = "POST")
    @RequestMapping("/modify_advise")
    public StatusResponse addAdvise(@RequestHeader(RequestConstant.TICKET) String ticket, String childrenId, String content) {

        StaffDTO staff = cache.getStaff(ticket);

        Boolean result = gardenLeaderService.addAdvise(staff, childrenId, content);

        return StatusResponse.success(result);
    }

}
